<?php
	include("connect.php");
	$css = '<link rel="stylesheet" type="text/css" media="all" href="asset/css/class_sellbook.css">';
	$title = 'Request Book';
	$page_name = 'request_book';
if(isset($_REQUEST["check"]))
{
	$title = "Edit Request Book";
	$requestbookid=$_REQUEST['requestbookid'];
	$sql = "select b.book_title, b.book_author,a.book_id from t_request_book a";
	$sql .= " inner join m_book b on a.book_id=b.book_id";
	$sql .= " where a.request_book_id=".$requestbookid;
	$retval = mysql_query( $sql, $con );
	if(! $retval )
	{
		die('Could not get data: ' . mysql_error());
	}
	while($row = mysql_fetch_array($retval))
	{
		$title = $row[0];
		$author = $row[1];
		$price = $row[2];
		$bookid=$row[2];
	}
	$type="edit";
}



?>

<?php
$sql = "select user_category from m_user where user_id=".$_SESSION['userid'];
$retval = mysql_query( $sql, $con );
while($row = mysql_fetch_array($retval))
	{
		$user_category = $row[0];
	}
if(isset($_SESSION["userid"]))
	{
		if($user_category ==9)
		{
			include("header_loggedinadmin.php");
		}else
		{
			include("header_loggedin.php");
		}
	}
else
{
	echo '<script>';
		echo "alert('Please Login!');";
		echo 'window.location = "index.php"';
		echo '</script>';}
?>

<div id="blue_bg">
	<div id="main">
        <div class="wrapper">
        	<div id="content">
            	<div id="white_box">
                	<h3 class="flag_long">REQUEST BOOK</h3>
                    <?php
					echo '
                    <form action="request_book_check.php" method="post">
					<input type="hidden" name="type" value="'.$type.'" />
					<input type="hidden" name="bookid" value="'.$bookid.'" />
					<input type="hidden" name="requestbookid" value="<?php echo $requestbookid;?>" />

                    <table>
                        <tr>
                            <td>Title</td>
                            <td width="50px"></td>
                            <td><input type="text" name="title" size="50" value="'.$title.'" /></td>
                        </tr>
                        <tr>
                            <td>Author</td>
                            <td width="50px"></td>
                            <td><input type="text" name="author" size="50" value="'.$author.'"/></td>
                        </tr>
                        <tr>
                            <td>Price</td>
                            <td width="50px"></td>
                            <td><input type="text" name="price" size="15" value="'.$price.'"/></td>
                        </tr>
						';
					echo '
                        <tr>
                            <td></td>
                            <td width="50px"></td>
                            <td><input type="submit" value="" id="submit_btn" /></td>
                        </tr>
                    </table>
                    </form>
					';
					?>
           		</div>
            </div>
        </div>
    </div>
</div>

<?php
 include("footer.php");
?>